<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>login</title>
    <script src="js/vue.js"></script>
    <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
    <script src="element-ui/lib/index.js"></script>
    <script src="api/axios-0.18.0.js"></script>
</head>

<body>
    <div id="app" class="container">
        <div class="login-wrapper">
            <div class="header">用户登录</div>
            <div class="form-wrapper">
                <input type="text" v-model="loginInformation.username" placeholder="用户名" class="input-item">
                <input type="password" v-model="loginInformation.password" placeholder="密码" class="input-item">
                <div class="btn" type="primary" @click="login">Login</div>
            </div>
            <div class="msg">
                没有账号?
                <a href="Register.html">注册</a>
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                loginInformation: {
                    username: '',
                    password: ''
                },
                //ipAndPort: 'http://localhost:8787',
            },
            methods: {
                login() {
                    this.listLoading = true;
                    if (this.loginInformation.username === '') {
                        this.$message({
                            type: 'error',
                            message: '请输入用户名'
                        });
                    }else if(this.password === ''){
                        this.$message({
                            type: 'error',
                            message: '请输入密码'
                        });
                    }else {
                        axios.get("/user/login", { params: this.loginInformation }).then((response) => {
                            if (200 === response.data.retCode) {
                                this.$message({
                                    type: 'success',
                                    message: '登录成功!'
                                });
                                window.open("HomePage.html", "_self");
                                //setTimeout(() => {window.open("F:/up/login-test-master/src/main/resources/static/HomePage.html", "_self");},1000);

                            } else {
                                this.$message({
                                    type: 'error',
                                    message: response.data.message
                                });
                            }
                            /* this.$message({
                                    type: 'success',
                                    message: '数据查询成功!'
                                }); */
                            this.listLoading = false;
                        });
                    }
                    console.log("登录");
                }

            },
        })
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
        }

        body {
            height: 100%;
        }

        .container {
            height: 100%;
            /*background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);*/
            background-image: linear-gradient(to right, #ffd04e, #68f5ba);
        }

        .login-wrapper {
            background-color: #fff;
            width: 358px;
            height: 588px;
            border-radius: 15px;
            padding: 0 50px;
            position: relative;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }

        .header {
            font-size: 38px;
            font-weight: bold;
            text-align: center;
            line-height: 200px;
        }

        .input-item {
            display: block;
            width: 100%;
            margin-bottom: 20px;
            border: 0;
            padding: 10px;
            border-bottom: 1px solid rgb(128, 125, 125);
            font-size: 15px;
            outline: none;
        }

        .input-item:placeholder {
            text-transform: uppercase;
        }

        .btn {
            text-align: center;
            padding: 10px;
            width: 100%;
            margin-top: 40px;
            background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
            color: #fff;
        }

        .msg {
            text-align: center;
            line-height: 88px;
        }

        a {
            text-decoration-line: none;
            color: #abc1ee;
        }
    </style>
</body>

</html>